package com.exam.vo;

import com.exam.entity.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.Date;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UserInfoVo {
    private Integer id;

    private String username;

    private String trueName;

    private  Integer roleId;

    private Integer status;

    private Date createDate;

    /**
     * 将User对象转换为UserInfoVo对象
     *
     * @param user User对象
     * @return UserInfoVo对象
     */
    public static UserInfoVo fromUser(User user){
        // 创建一个UserInfoVo对象
        UserInfoVo userInfoVo=new UserInfoVo();
        // 使用BeanUtils工具类将User对象的属性复制到UserInfoVo对象中
        BeanUtils.copyProperties(user,userInfoVo);
        // 返回UserInfoVo对象
        return userInfoVo;
    }

}
